#include <bits/stdc++.h>
using namespace std;
int a;
vector<int> b;
int N;

bool run(){
    stack<int> c;
    for (int i = 0; i < N;) {
        if(b[i] == a) {++i; ++a;}
        else if(!c.empty() && b[i] == c.top()) {++i; c.pop();}
        else if(a <= N) {c.push(a); ++a;}
        else return false;
    }
    return true;
}

int main() {
    ios_base::sync_with_stdio(false);cin.tie(nullptr);
    while(cin >> N && N != 0){
        int t;
        while(cin >> t && t!=0){
            a = 1;
            b.clear(); b.push_back(t);
            for (int i = 2; i <= N; ++i) {
                cin >> t; b.push_back(t);
            }
            if(run()) cout << "Yes\n";
            else cout << "No\n";
        }
        cout << "\n";

    }
    return 0;
}